package android.framework.widget.scrollview;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * 可观察的scrollver
 * 
 * @ClassName: ObservableScrollView
 * @Description: TODO
 * @author jtf19@163.com
 * @date 2013-7-23 下午2:21:29
 * 
 */
public class ObservableScrollView extends ScrollView {
	private ScrollCallbacks mCallbacks;

	public ObservableScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
		super.onScrollChanged(l, t, oldl, oldt);
		if (mCallbacks != null) {
			mCallbacks.onScrollChanged(l, t, oldl, oldt);
		}
	}

	@Override
	public int computeVerticalScrollRange() {
		return super.computeVerticalScrollRange();
	}

	public void setCallbacks(ScrollCallbacks listener) {
		mCallbacks = listener;
	}

	@Override
	public void draw(Canvas canvas) {
		super.draw(canvas);
	}

	static interface ScrollCallbacks {
		public void onScrollChanged(int l, int t, int oldl, int oldt);
	}
}